package com.x.example.toolbar.items;

import android.content.Context;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.example.uiframework.utils.Utils;
import com.x.uikit.toolbar.XToolbarItem;
public class TitleItem extends XToolbarItem {
    TextView mTvTitle;

    public TitleItem(@NonNull Context context, @NonNull String token) {
        super(context, token);
        mTvTitle = new TextView(getContext());
        mTvTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
        mTvTitle.setTextColor(0xff333333);
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.CENTER_VERTICAL;
        mTvTitle.setEllipsize(TextUtils.TruncateAt.END);
        this.addView(mTvTitle, lp);
    }

    public void setSingleLine(boolean enable) {
        mTvTitle.setSingleLine(enable);
    }

    public void setTitle(CharSequence title) {
        mTvTitle.setText(title);
    }
}
